package jgl.vajra.management.part.vehicle.activity;

import androidx.recyclerview.widget.LinearLayoutManager;

import com.gyf.immersionbar.ImmersionBar;

import java.util.ArrayList;
import java.util.List;

import jgl.vajra.management.R;
import jgl.vajra.management.databinding.ActivityOwnerDetailsBinding;
import jgl.vajra.management.part.vehicle.contract.OwnerDetailsContract;
import jgl.vajra.management.part.vehicle.viewModel.OwnerDetailsViewModel;
import jgl.vajra.management.widget.databindingadapter.BaseBindingItemPresenter;
import jgl.vajra.management.widget.databindingadapter.SingleTypeBindingAdapter;
import jgl.vajra.management.widget.mvvm.factory.CreateViewModel;
import jgl.vajra.management.widget.mvvm.view.BaseMVVMActivity;
import jgl.vajra.management.widget.utils.ToastUtils;

@CreateViewModel(OwnerDetailsViewModel.class)
public class OwnerDetailsActivity extends BaseMVVMActivity<OwnerDetailsViewModel, ActivityOwnerDetailsBinding> implements OwnerDetailsContract.View, BaseBindingItemPresenter {

    private boolean isCollection;
    private SingleTypeBindingAdapter<Object> vehicleAdapter;
    private SingleTypeBindingAdapter<Object> orderAdapter;
    private SingleTypeBindingAdapter<Object> evaluateAdapter;

    @Override
    public int getLayoutId() {
        return R.layout.activity_owner_details;
    }

    @Override
    public void initView() {
        super.initView();
        mBinding.setView(this);

        ImmersionBar.with(this).statusBarColor(R.color.color_012BB2).navigationBarColor(R.color.white).fitsSystemWindows(true).statusBarDarkFont(false, 0.2f).init();

        mBinding.toolbar.setNavigationIcon(R.drawable.ic_left_arrow_white);
        mBinding.toolbar.setNavigationOnClickListener(view -> finish());

        List<String> list = new ArrayList<>();
        list.add("");
        list.add("");
        list.add("");
        list.add("");

        // 不可嵌套滑动
        mBinding.vehicleRecyclerView.setNestedScrollingEnabled(false);
        // 取消head 的 recycleView的焦点
        mBinding.vehicleRecyclerView.setFocusableInTouchMode(false);
        //设置布局管理器
        mBinding.vehicleRecyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
        vehicleAdapter = new SingleTypeBindingAdapter<>(this, list, R.layout.item_owner_details_vehicle);
        mBinding.vehicleRecyclerView.setAdapter(vehicleAdapter);
        vehicleAdapter.setItemPresenter(this);

        // 不可嵌套滑动
        mBinding.orderRecyclerView.setNestedScrollingEnabled(false);
        // 取消head 的 recycleView的焦点
        mBinding.orderRecyclerView.setFocusableInTouchMode(false);
        //设置布局管理器
        mBinding.orderRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        orderAdapter = new SingleTypeBindingAdapter<>(this, list, R.layout.item_owner_details_order);
        mBinding.orderRecyclerView.setAdapter(orderAdapter);
        orderAdapter.setItemPresenter(this);

        // 不可嵌套滑动
        mBinding.evaluateRecyclerView.setNestedScrollingEnabled(false);
        // 取消head 的 recycleView的焦点
        mBinding.evaluateRecyclerView.setFocusableInTouchMode(false);
        //设置布局管理器
        mBinding.evaluateRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        evaluateAdapter = new SingleTypeBindingAdapter<>(this, list, R.layout.item_owner_details_evaluate);
        mBinding.evaluateRecyclerView.setAdapter(evaluateAdapter);
        evaluateAdapter.setItemPresenter(this);

    }

    //收藏
    @Override
    public void onCollection() {
        isCollection = !isCollection;
        if (isCollection) {
            mBinding.ivCollection.setImageResource(R.drawable.ic_collection_select);
            ToastUtils.showShort("收藏成功");

        } else {
            mBinding.ivCollection.setImageResource(R.drawable.ic_collection);
            ToastUtils.showShort("取消收藏");
        }

    }

    //全部干活地
    @Override
    public void onHistoricalOrder() {
        ToastUtils.showShort("全部干活地");
    }

    //全部曝光
    @Override
    public void onFullExposure() {
        ToastUtils.showShort("全部曝光");
    }

    @Override
    public void onItemClick(int position, Object itemData) {

    }
}
